
require.config({
    baseUrl:"../",
    paths:{
        jquery:"lib/jquery.min",
        handlebars:"lib/handlebars.min",
        text:"lib/requirejs/text.min",
        style:"lib/requirejs/css.min",
        myHandle:"js/myHandle",
        zTree:'lib/zTree_v3/js/jquery.ztree.all',
        'zTree.exhide':'lib/zTree_v3/js/jquery.ztree.exhide',

        toast: 'components/toast/toast',

        Router: 'components/router/router',
        TreeTable: 'components/treeTable/treeTable',
        Upload: 'components/upload/upload',
        Switch: 'components/switch/switch',
        Table: 'components/table/table',
        Pagination: 'components/pagination/pagination',
        breadNav: 'components/breadNav/breadNav',
        Nav: "components/nav/nav",
        Tree: "components/tree/tree",
        Step: "components/step/step",
        MyStep: "components/myStep/myStep",
        Popover: "components/popover/popover",
        SelectTree: "components/selectTree/selectTree",

        common: 'js/common'
    },
    shim:{
        zTree : { deps:['jquery'], exports:'$.fn.zTree' },
        'zTree.exhide': {
            deps: ['zTree']
        },
        toast: {
            deps: ['jquery'],
            exports: '$.fn.toast'
        }
    }
})

require([
    'Router', 'Nav', "routes/index", 'routes/list', 'routes/demo', 'toast', 'zTree'
],
function(Router, Nav, indexPage, listPage, demoPage){
    window.$app = {};
    $app.router = new Router([
        { path:"", component: indexPage },
        { path:"list", component: listPage },
        { path:"demo", component: demoPage }
    ]);
    var leftNav = new Nav({
        id: "navBox",
        navList: [
            { name: "首页", path: "" },
            { name: "列表", path: "list" },
            { name: "加载中", path: "loading" },
            { name: "demo", path: "demo" },
        ],
        onItemClick: function(item){
            window.location.href = '#' + item.path;
        }
    })
    $(document).on("click", '.bar', function(e){
        var _this = e.target;
        if($(".nav-box").hasClass("left")){
            $(".nav-box").animate({
                width:"160px"
            }, 500, 'linear', function(){
                $(this).removeClass('left');
            })
            $(".content").animate({
                marginLeft:"160px"
            }, 500, 'linear', function(){
                $(this).removeClass('left');
            })
        }else{
            $(".nav-box").animate({
                width:"60px"
            }, 500, 'linear', function(){
                $(this).addClass('left');
            }).addClass('left');
            $(".content").animate({
                marginLeft:"60px"
            }, 500, 'linear', function(){
                $(this).addClass('left');
            })
        }
    })
    // index();
    // setMenu();
    // // console.log(Upload);
    // var uploadFile = new Upload({
    //     el:"#upload",
    //     message:"请上传文件",
    //     download:function(){
    //         console.log("download");
    //     }
    // })
    // $(document).on('click', '.btns .clearFile', function(e){
    //     uploadFile.clearFile();
    // })
    // $(document).on('click', '.btns .getFile', function(e){
    //     var files = uploadFile.getFile();
    //     console.log(files);
    // })
    // $(document).on('click', '.btns .submit', function(e){
    //     uploadFile.submit('/upload', function(res){
    //         console.log(res);
    //     }, function(rate){
    //         console.log(rate);
    //     })
    // })

})
